package com.itheima.jobs;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.service.OrderSettingService;
import com.itheima.utils.DateUtils;

import java.util.Calendar;
import java.util.Date;

public class ClearOrderSettingJob {
    @Reference
    private OrderSettingService orderSettingService;

    public void clearOrderSetting(){
        Calendar c=Calendar.getInstance();
        c.add(Calendar.MONTH,-1);
        Date date=c.getTime();
        try {
            String orderDate = DateUtils.parseDate2String(date);
            System.out.println(orderDate);
            /*orderSettingService.deleteOrderSettingByDate("2019-04-25"); //测试数据*/
            orderSettingService.deleteOrderSettingByDate(orderDate);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
